function measure();
h = figure;
h1 = textentry('Coord', 'Coords', '0,0', 35, 0.05, 0.05);
axis([0 10 0 10])
     hold on

     % Initially, the list of points is empty.
     x = [];
     y = [];
     n = 0;
ax=axis; % get axis limits for display
     % Loop, picking up the points.
     disp('Left mouse button picks points.')
     disp('Right mouse button draws horizontal reference line')
     but = 1;
     y0=0;
     hl=[];
     hp=[];
     while but ~= 2 % hit both simultaneously to quit
        [xi,yi,but] = ginput(1);
        yn=yi-y0;
% in any case, display what we need to know        
         set(h1, 'String', sprintf('%7.2f, %7.2f', xi, yn));
         n = n+1;
         x(n,1) = xi;
         y(n,1) = yi-y0;
        switch(but) % then do what we need to do to read the data.
        case 1 % left button - draw a crosshair
	        if(isempty(hp))
      	     hp=plot(xi,yi,'g+', 'MarkerSize', 24, 'EraseMode', 'xor') % Mark absolute position
	        else
      	     set(hp, 'XData', xi, 'YData', yi);
           end;
           set(hp, 'Visible', 'on');
        case 3 % right button - draw a reference line
            % hide the crosshair we drew
            if(~isempty(hp))
               set(hp, 'Visible', 'off');
            end;
            if(isempty(hl)) % first line we draw
               hl=line([ax(1) ax(2)], [yi yi], 'Color', 'k', 'LineStyle', '--', 'EraseMode', 'xor');
            else
               set(hl, 'Ydata', [yi yi]);
            end;
           y0=yi; % that's the NEW reference point
        case 2
           break;
        otherwise
        end;
      end

clf;
close all hidden;
return;


% textentry.m - make a textbox with a label
% call: textbox(tag, label, initvalue, x, y)
% x and y are in character units...
function [handle] = textentry(tag, label, initvalue, fieldwidth, x, y)

b_ht = 1.4; % standard field height in characters
pad_static=4;
pad_edit=5;
fontsz=10;
fwtitle = length(label)+pad_static;
fwarg = fieldwidth+pad_edit - fwtitle;
if(fwarg < (length(initvalue)+pad_edit+1)) fwarg = length(initvalue)+pad_edit+1;
end
h1 = uicontrol('Units','characters', ...
	'ListboxTop',0, ...
   'Position',[x y fwtitle b_ht], ...
   'HorizontalAlignment','left', ...
   'String',label, ...
	'Style','text', ...
   'FontSize', fontsz);
handle = uicontrol('Units','characters', ...
	'ListboxTop',0, ...
   'background', [1 1 1], ...
   'foreground', 'black', ...
   'Position',[x+fwtitle y fwarg b_ht], ...
   'HorizontalAlignment','right', ...
   'Max', 1, ...
	'Min', 0, ...
   'Style','edit', ...
   'FontSize', fontsz, ...
   'Tag',tag);
set(handle, 'String', initvalue);
return

